package com.xiaohong.file.feign;

import com.xiaohong.file.fallback.FileFallback;
import entity.Result;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author : xiaohong
 * @date : 2021/5/19 8:59
 */
@FeignClient(name="xiaohong-file",contextId = "file",fallback= FileFallback.class)
public interface FileFeign {

    /**
     * 上传文件
     * @param file
     * @return
     * @throws Exception
     */
    @PostMapping(value ="/file/upload",consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    Result uploadFile(@RequestPart(value = "file") MultipartFile file);

    /**
     * 文件下载
     * @param fileUrl
     * @param downloadUrl
     * @return
     * @throws Exception
     */
    @PostMapping(value = "/file/download")
    Result downloadFile(@RequestPart(value = "fileUrl") String fileUrl,@RequestPart(value = "downloadUrl") String downloadUrl);

    /**
     * 文件删除
     * @param fileUrl
     * @return
     * @throws Exception
     */
    @DeleteMapping(value = "/file/delete")
    Result deleteFile(@RequestParam(value = "fileUrl") String fileUrl);

    /**
     * 文件详情获取
     * @param url
     * @return
     */
    @GetMapping("/file")
    Result getFileInfo(@RequestParam String url);

}
